    /**
    * @author: ChengJW
    * @params:
    * @return:
    * @date: 2021/9/16
    * @description: 加载 layUi 模块
    */
    layui.use(['layer','form','carousel'],function (){
        let layer = layui.layer,form = layui.form,carousel = layui.carousel;
    });

    /**
    * @author: ChengJW
    * @params:
    * @return:
    * @date: 2021/9/16
    * @description: 初始化加载验证码
    */
    $(function (){
        if(top != window){
            top.location.href = window.location.href;
        }
        createCheckCode();
        visitor();
    });

    /**
    * @author: ChengJW
    * @params:
    * @return:
    * @date: 2021/12/26
    * @description: 记录游客到访登录页面
    */
    function visitor() {
        //调用接口，获取游客访问的城市
        let jsonData = {
            "city": returnCitySN.cname
        }
        sendAjax("/visitor",jsonData,function (result) {

        })
    }

    /**
    * @author: ChengJW
    * @params:
    * @return:
    * @date: 2021/9/16
    * @description: 生成或刷新验证码
    */
    function createCheckCode(){
        sendAjax("/showCheckCOde",null,function (result) {
            if (result.code == '00'){
                $(".span_checkCode").html(result.data);
                //开发使用
                $(".checkCode").val(result.data);
            }else {
                layer.msg("抱歉，加载验证码失败!",{icon:5});
            }
        })
    }

    /**
    * @author: ChengJW
    * @params:
    * @return:
    * @date: 2021/11/04
    * @description: 登录
    */
    function login() {
        let userName = $('.userName').val().trim();
        let passWord = $('.passWord').val().trim();
        let checkCode = $('.checkCode').val().trim().toLowerCase();
        let innerCheckCOde = $('.span_checkCode').html().toLowerCase();

        //判断账号密码是否为空
        if (valueIsEmpty(userName) || valueIsEmpty(passWord)){
            layer.alert('Username or password is null,please try again',{title:'Notice'});
            return;
        }

        //判断验证码输入是否正确
        if (valueIsEmpty(checkCode) || !valueIsEqual(checkCode,innerCheckCOde)){
            layer.alert('Verification code is wrong,please check it',{title:'Notice'});
            $('.checkCode').val("");
            createCheckCode();
            return;
        }
        let jsonData = {
            "userName":userName,
            "passWord":passWord
        };
        sendAjax("/UserLogin",jsonData,function (result) {
            let codeV = result.code;
            if (valueIsEqual(codeV,'00')){
                window.location.href = '/userinfo/index';
                visitor();
            }else if (valueIsEqual(codeV,'01')){
                layer.alert(result.msg,{title:'Notice'},function (){
                    window.location.reload();
                });
            }else if (valueIsEqual(codeV,'02')){
                layer.alert(result.msg,{title:'Notice'},function (){
                    window.location.reload();
                });
            }
        })
    }
